//
//  RecentSevenDayAxisValueFormatter.swift
//  MoyoungHome
//
//  Created by 李然 on 2022/9/28.
//

import UIKit
import Charts
import SwiftDate

public class RecentSevenDayAxisValueFormatter: NSObject,IAxisValueFormatter {
    
    public var axisValueArray:[String] = []
    
    public init(date:Date){
        
        self.axisValueArray = (0..<7).map({ index in
            let newDate = date - index.days
            return "\(newDate.month)/\(newDate.day)"
        }).reversed()
    }
    
    public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        let index = Int(Int(value) % self.axisValueArray.count)
        return self.axisValueArray[index]
    }
}
